import 'package:flutter/material.dart';

/**
 * Text样式
 */
class TextDemo extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text("TextDemo")),
        body: Column(
          children: <Widget>[
            Text("Hello world",
                style: TextStyle(
                    color: Colors.redAccent
                )
            ),
            /**
             * ellipsis
             * textAlign:gravity
             */
            Text("Hello world! I'm Jack. " * 4,
              maxLines: 2,
              overflow: TextOverflow.ellipsis,
              textAlign: TextAlign.center,
            ),
            /**
             * textScale
             */
            Text("Hello world",
              textScaleFactor: 1.5,
            ),
            Text("Amazing",
              style: TextStyle(
                  color: Colors.blue,
                  fontSize: 18.0,
                  height: 1.2,
                  fontFamily: "Courier",
                  background: new Paint()
                    ..color = Color.fromARGB(255, 180, 180, 180),
                  decoration: TextDecoration.underline,
                  decorationStyle: TextDecorationStyle.dashed
              ),
            ),
            /**
             * 富文本
             */
            Text.rich(TextSpan(
                children: [
                  TextSpan(
                      text: "tSpan0"
                  ),
                  TextSpan(
                      text: "tSpan1",
                      style: TextStyle(
                          color: Colors.redAccent,
                          fontSize: 38,
                          decoration: TextDecoration.lineThrough
                      )
//                      recognizer: _tapRecognizer
                  )
                ]
            )),
            /**
             * 继承style的layout
             */
            DefaultTextStyle(
              style: TextStyle(
                color: Colors.greenAccent,
                fontSize: 20,
                fontStyle: FontStyle.italic,
              ),
              child: Column(
                children: <Widget>[
                  Text("Hello world"),
                  Text("Hello world"),
                  Text("Hello world"),
                  Text("Hello world"),
                  Text("Hello world",
                      style: TextStyle(
                          color: Colors.redAccent
                      )
                  ),
                ],
              ),
            )
          ],
        )
    );
  }
}